import re

class ContainerResponse:
    def __init__(self, response):
        self.data = None
        self.page = None
        re_html = re.compile('<html\s.*>')
        re_chead = re.compile('[^\x0A]*\x0A?[^\x0A]*\x0A?\x0A?')
        elem = re_html.split(response.content)
        if len(elem) >= 2:
            self.data = '<html>' + elem[1]
            self.page = True
        else:
            self.data = re_chead.split(response.__str__(), 1)[1]
            self.page = False

    def __str__(self):
        return data

def startcontainer(status, response_headers, exec_info = None):
    pass

def getresponsecookie(cookies, response):
    try:
        if response.cookies:
            print response
            re_setcookie = re.compile('^Set-Cookie:\s')
            return re_setcookie.sub('', response.cookies.__str__())
        else:
            return cookies
    except:
        return cookies